<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    // 有参
    let add = (x, y) => x + y
    console.log(add(5, 10))

    // 无参
    let printTime = () => '现在的时间是:' + new Date()
    console.log(printTime())

    // 对象作为参数
    let getObj = id => {
        return {
            id: id,
            name: 'jack'
        }
    }
    // 对象作为参数 第二种
    let getObj2 = id => ({id: id, name: 'marry'})
    console.log(getObj(12))
    console.log(getObj2(20))

    // 闭包函数
    let f1 = (function(){
        return function(){
            console.log('hello ES6')
        }
    })();
    f1();

    // 闭包函数2
    let f2 = (()=>{
        return ()=>{
            console.log('f2')
        }
    })();

    f2()


</script>
</body>
</html>
